from openpyxl import load_workbook

'''
# sheet相关操作
# # workbook
# wb = load_workbook('p1.xlsx')

# # 获取所有的sheet名称
# name_list = wb.sheetnames
# print(name_list)    # ['products']

# # 根据名称获取sheet
# sheet_obj = wb['products']
# print(sheet_obj)    # <Worksheet "products">
# cell = sheet.cell(1,2)  # 第一行第二列的单元格
# print(cell.value)   # 第一行第二列的单元格的值

# # 根据索引获取sheet
# wb = load_workbook('p1.xlsx')
# sheet = wb.worksheets[0]
# cell = sheet.cell(1,2)  # 第一行第二列的单元格
# print(cell.value)   # 第一行第二列的单元格的值

# # 循环所有的sheet
# for sheet_obj in wb:
#     print(sheet_obj)

# for name in wb.sheetnames:
#     sheet = wb[name]
#     cell = sheet.cell(1,2)
#     print(cell.value)

# for sheet in wb.worksheets:
#     cell = sheet.cell(1, 1)
#     print(cell.value)
'''

wb = load_workbook('files/p1.xlsx')
sheet = wb['products']
cell = sheet.cell(1,2)  # 第一行第二列的单元格
print(cell.value)   # 第一行第二列的单元格的值

# for sheet in wb.worksheets:
#     cell = sheet.cell(1, 1)
#     print(cell.value)
